// #ifdef APP-PLUS
const dcRichAlert = uni.requireNativePlugin('Trader')
const SjkfAlert = uni.requireNativePlugin('Sjkf')
// #endif

//  开户
export function openAccount() {
	return new Promise((resolve, reject) => {
		SjkfAlert.init({
			brokerId: uni.getStorageSync('brokerId'),
			url: uni.getStorageSync('cfmmcUrl'),
			channel: uni.getStorageSync('channel')
		}, function(res) {
			if (res.code === 200) {
				resolve(res)
			} else {
				reject(res)
			}
		})
	})
}

//  资金详情
export function init () {
	return new Promise((resolve, reject) => {
		dcRichAlert.init({
			serviceUrl: 'tcp://180.169.252.138:51207',
			userProductInfo: 'souliang',
			appid: 'cqwz_slw_1.0.0',
			authCode:  '5OFF3EPKV150ZY2Z',
			brokerId: '0155',
			userId: '09999',
			password: '78938897ww',
		}, function(res) {
			if (res.code === 200) {
				resolve(res)
			} else {
				reject(res)
			}
		})
	})
}
//  重置密码
export function updatePassword (data) {
	return new Promise((resolve, reject) => {
		dcRichAlert.updatePassword(data, function(res) {
			if (res.code === 200) {
				resolve(res)
			} else {
				reject(res)
			}
		})
	})
}

//  资金详情
export function reqQrySecAgentTradingAccount (data) {
	return new Promise((resolve, reject) => {
		dcRichAlert.reqQrySecAgentTradingAccount({}, function(res) {
			if (res.code === 200) {
				resolve(res)
			} else {
				reject(res)
			}
		})
	})
}

//交易:180.168.146.187:10130,行情:180.168.146.187:1013  tcp://180.168.146.187:10100 ,
export function Traderinit () {
	return new Promise((resolve, reject) => {
		dcRichAlert.init({
			appId: "SHINNY_Q7V3_3.8",
			authCode: "XLRIQTTFTZ660E4K",
			brokerId: "4040",
			password: "z12345678",
			serviceUrl: "tcp://180.166.103.21:55205",
			userId: "0210000911",
			userProductInfo: "SHINNY",
		}, function(res) {
			if (res.code === 200) {
				resolve(res)
			} else {
				reject(res)
			}
		})
	})
}
